package com.itheima;

import com.itheima.dao.impl.GoodsDaoImpl;
import com.itheima.domain.Goods;
import com.itheima.domain.Order;
import com.itheima.domain.User;
import com.itheima.service.OrderService;
import com.itheima.service.impl.OrderServiceImpl;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class App {
    public static void main(String[] args) {
        Order order = new Order();

        User user = new User();
        user.setUserName("Spring小助手");
        user.setAddress("编程大街201号");

        Goods goods = new Goods();
        goods.setGoodsName("《Spring百科全书》");
        goods.setNum(45);


        //TODO 创建配置类          提示:@Configuration   @ComponentScan("com.itheima")
    //    ClassPathXmlApplicationContext classPathXmlApplicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");

        //TODO 使用spring创建对象  提示:AnnotationConfigApplicationContext
        AnnotationConfigApplicationContext annotationConfigApplicationContext = new AnnotationConfigApplicationContext("ApplicationConfig.class");
      //  OrderService orderService1 = (OrderService) annotationConfigApplicationContext.getBean(OrderService.class);
        //orderService1.placeOrder(order,user,goods);
       // OrderService orderService = new OrderServiceImpl();
      //  orderService.placeOrder(order, user, goods);
        GoodsDaoImpl goodDaoImpl = (GoodsDaoImpl) annotationConfigApplicationContext.getBean("goodsDaoImpl");
        goodDaoImpl.save();
    }

}
